package com.wnx.job.common.utils;

import java.util.Random;

/**
 * @author wangnaixing
 */
public class StrUtils {

    /**
     * 截取字符串长度
     * @param olderStr
     * @return
     */
    public static String CutString(String olderStr) {
        return olderStr.length() > 12 ? olderStr.substring(0,12)+"...": olderStr;
    }

    /**
     * 截取字符串长度
     * @param olderStr
     * @return
     */
    public static String CutString(String olderStr,int size) {
        return olderStr.length() > size ? olderStr.substring(0,size)+"...": olderStr;
    }


    /**
     * 生成6位随机数
     * @return
     */
    public static String randomCode() {
        StringBuilder stringBuilder = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < 6; i++) {
            stringBuilder.append(random.nextInt(10));
        }
        return stringBuilder.toString();
    }




}
